//
//  WYNewsNormalCell.m
//  WYNews
//
//  Created by 曾佳豪 on 2017/3/20.
//  Copyright © 2017年 haodada.com. All rights reserved.
//

#import "WYNewsNormalCell.h"
#import <Masonry.h>
#import <UIImageView+WebCache.h>
@implementation WYNewsNormalCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self =[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}
-(void)setupUI{
    //创建并添加子控件
    
    _newsImage =[[UIImageView alloc]init];
    [self.contentView addSubview:_newsImage];
    
    _newsTitle =[UILabel new];
    [self.contentView addSubview:_newsTitle];
    
    _newsTitle.font =[UIFont systemFontOfSize:18];
    _newsTitle.textColor =[UIColor blackColor];
    _newsTitle.numberOfLines =0;
    
    _source =[[UILabel alloc]init];
    [self.contentView addSubview:_source];
    
    _source.font =[UIFont systemFontOfSize:15];
    _source.textColor =[UIColor lightGrayColor];
    
    _replyCount =[UILabel new];
    [self.contentView addSubview:_replyCount];
    _replyCount .font =[UIFont systemFontOfSize:15];
    _replyCount .textColor =[UIColor lightGrayColor];
    
    //加约束
    [_newsImage mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.contentView).offset(8);
        make. left.equalTo(self.contentView).offset(10);
        make.bottom.equalTo(self.contentView).offset(-10);
         make.size.mas_equalTo(CGSizeMake(102, 76));
    }];
    [_newsTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_newsImage);
        make.left.equalTo(_newsImage.mas_right).offset(10);
        make.right.equalTo(self.contentView).offset(-10);
    }];
    
    [_source mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_newsImage);
        make.left.equalTo(_newsImage.mas_right).offset(10);
    }];
    
    [_replyCount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_newsImage);
        make.right.equalTo(self.contentView).offset(-10);
    }];
 
}
-(void)setModel:(WYNewsModel *)model{
    _model= model;
    [_newsImage sd_setImageWithURL:[NSURL URLWithString:_model.imgsrc]];
    _newsTitle.text =_model.title;
    _source.text =_model.source;
    _replyCount.text=_model.replyCount;
    
    
    
}

@end
